<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="签约单号" prop="FBILLNO">
            <el-input v-model="dataForm.FBILLNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="签约日期" prop="FBILLCREDATE">
            <el-date-picker v-model="dataForm.FBILLCREDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="签约状态">
              <el-select v-model="dataForm.FBILLSTATE" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>


        <el-col :span="8">
          <el-form-item label="签约人员" prop="FUSER">
            <el-input v-model="dataForm.FUSER"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="供应商">
              <el-select v-model="dataForm.FSUPPLIER" placeholder="请选择" >
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
          <el-form-item label="签约费用" prop="FAMT">
            <el-input v-model="dataForm.FAMT"   />
          </el-form-item>
        </el-col>


        <el-col :span="8">
          <el-form-item label="合约起日" prop="FBEGDATE">
            <el-date-picker v-model="dataForm.FBEGDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="合约讫日" prop="FENDDATE">
            <el-date-picker v-model="dataForm.FENDDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="审核人员" prop="FCHECKUSE">
            <el-input v-model="dataForm.FCHECKUSE" disabled  />
          </el-form-item>
        </el-col>


         <el-col :span="8">
          <el-form-item label="签约说明" prop="FMEMO">
            <el-input v-model="dataForm.FMEMO"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="审核日期" prop="FCHECKDATE">
            <el-input v-model="dataForm.FCHECKDATE"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加设备</el-button> -->
            <el-button type="primary" :loading="loading">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <template>
    <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="设备列表" name="first">
        <el-table :data="list" border stripe>
        <el-table-column label="操作" width="80">
          <template slot-scope="scope">
            <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
              type="text">删除</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="FENTRYID" label="序号" width="85"></el-table-column>
        <el-table-column prop="FTYPE" label="设备类型" ></el-table-column>
        <el-table-column prop="FCATNAME" label="设备名称" ></el-table-column>
        <el-table-column prop="FBRAND" label="设备品牌" ></el-table-column>
        <el-table-column prop="FSPEC" label="设备型号" ></el-table-column>
        <el-table-column prop="FUNIT" label="设备单位" width="85"></el-table-column>
        <el-table-column prop="FMEMO" label="备注" ></el-table-column>
        </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
    </el-tab-pane>

    <el-tab-pane label="维修工程师列表" name="second">
      <el-table :data="list2" border stripe>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
            type="text">删除</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="FENTRYID" label="序号" width="85"></el-table-column>
      <el-table-column prop="FWORKNAME" label="工程师姓名" ></el-table-column>
      <el-table-column prop="FTELNO" label="手机号码" ></el-table-column>
      <el-table-column prop="FEMAIL" label="邮箱地址" ></el-table-column>
      <el-table-column prop="FMEMO" label="备注" ></el-table-column>
     </el-table>

     <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
     </div>
    </el-tab-pane>
  </el-tabs>
</template>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        activeName: 'first',
        title: "新增",
        insertorupdate: true,
        dataForm: {
            FBILLNO: "K241130002", 
            FBILLCREDATE:"2024-11-30",
            FUSER: "刘庄",
            FMEMO: "有机化学实验操作课",
            FBEGDATE: "2024-12-01",
            FENDDATE: "2025-11-30",
            FSTOCK:"化学系仓库",
            FSUPPLIER:"江苏艾普瑞实验设备有限公司",
            FAMT:"780000",
            FCHECKUSE: "汉武帝",
            FCHECKDATE: "2024-11-30 13:50:01",
            FNOTE:"",
            FBILLSTATE: "未生效"
        },
        rules: {
          FUSER: [
            { required: true, message: '请输入签约人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入签约说明', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FTYPE":"通风柜",
                  "FCATNAME": "锡好通风柜",
                  "FBRAND":"锡好",
                  "FSPEC":"Gv100",
                  "FUNIT": "台",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FTYPE":"压力柜",
                  "FCATNAME": "锡好压力柜",
                  "FBRAND":"锡好",
                  "FSPEC":"TP090",
                  "FUNIT": "台",
                  "FMEMO": ""
                }],
        
        list2: [{ "FENTRYID":1,
                  "FWORKNAME": "岳飞",
                  "FTELNO":"166098723345",
                  "FEMAIL":"166098723345@qq.com",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FWORKNAME": "司马光",
                  "FTELNO":"13987652345",
                  "FEMAIL":"13987652345@qq.com",
                  "FMEMO": ""
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '1',
          label: '未生效'
        }, {
          value: '2',
          label: '已生效'
        }, {
          value: '3',
          label: '已驳回'
        }],

        //仓库
        options2: [{
          value: '1',
          label: '广州福兴实验室设备科技'
        }, {
          value: '2',
          label: '江苏艾普瑞实验设备有限公司'
        }, {
          value: '3',
          label: '山东德瑞克仪器股份有限公司'
        }],

        //供应商
        options3: [{
          value: '1',
          label: '奉1教楼101'
        }, {
          value: '2',
          label: '奉1教楼102'
        }, {
          value: '3',
          label: '奉综合楼201'
        }, {
          value: '4',
          label: '奉综合楼202'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>